<template>
  <div>
    <Header :scrollDistance="scrollDistance">
      <div slot="hidden" class="hidden">
        <h1 class="title">{{ questionInfo.title }}</h1>
        <followButton class="follow-question button" />
        <write-button class="write-answer button" />
      </div>
    </Header>
  </div>
</template>
<script>
import Header from "@/components/header/Header";
import WriteButton from "@/components/question/button/WriteButton";
import FollowButton from "@/components/question/button/FollowButton";

export default {
  name: "QuestionHeader",
  components: {
    Header,
    WriteButton,
    FollowButton,
  },
  props: {
    questionInfo: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      scrollDistance: 450,
    };
  },
  mounted() {
    //接收事件
    this.$Bus.$on("show", (offHeight) => {
      this.scrollDistance = offHeight;
    });
  },
  beforeDestroy() {
    this.$Bus.$off("show");
  },
};
</script>

<style scoped lang="scss">
.hidden {
  position: relative;
  height: 6rem;
  display: flex;
  align-items: center;
  .title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 67.4rem;
    line-height: 3.2rem;
    font-size: 2.2rem;
    font-weight: 600;
  }
  .button {
    position: absolute;
  }
  .follow-question {
    right: 11rem;
  }
  .write-answer {
    right: 0;
  }
}
</style>
